home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 September
/
Chip_2004-09_cd1.bin
/
program
/
delphi
/
download
/
nastroje
/
97.mpth_10[1].exe
/
{app}
/
scripts
/
Checksums.mps
next >
Wrap
Text File
|
2003-10-17
|
2KB
|
83 lines
include 'def.mps'
= create crc16, crc32 and md5 checksum of the current file
= ensure a current file is available
if currentfile==''
!cmd.fileopen
if currentfile==''
end
endif
endif
= create a temporary filename
var ftemp text dw dword
repeat
dw = random(0xffffffff)+1
ftemp = envparse('%temp%\mpth_s'+text(dw))
until not fileexists(ftemp)
= copy the current data to the temporary file
var fin file fout file
fout=fileopen(ftemp,'c')
fin=fileopen('::current', 'r')
= check if a selection is available
var dosave byte
dosave = 1
if filegetprop(fin, 'selcount') != 0
var mb dword
mb = msgbox('Use only the selected data for checksum calculation?', MB_ICONQUESTION or MB_YESNOCANCEL)
if mb == IDCANCEL: end:endif
if mb == IDYES
fileclose fout
!cmd.filesaveselection ftemp
dosave = 0
endif
endif
if dosave
var data text read dword
repeat
read=fileread(fin, @data, 65536)
if read > 0
data = textcopy(data, 1, read)
filewrite fout data
endif
until read == 0
fileclose fout
endif
fileclose fin
= execute the three programs
var crc16 text crc32 text md5 text msg text
read = shell(envparse('%apppath%\utils\crc1632.exe'), ('/m16 "/f'+ftemp+'"'), 0, '', @crc16)
if read == 0
concat msg ("CRC16 checksum:\r\n "+textchop(textupper(crc16))+"\r\n\r\n")
endif
read = shell(envparse('%apppath%\utils\crc1632.exe'), ('/m32 "/f'+ftemp+'"'), 0, '', @crc32)
if read == 0
concat msg ("CRC32 checksum:\r\n "+textchop(textupper(crc32))+"\r\n\r\n")
endif
read = shell(envparse('%apppath%\utils\md5.exe'), ('"'+ftemp+'"'), 0, '', @md5)
if read == 0
read = textpos(' ', md5)
md5 = textcopy(md5, 1, read-1)
concat msg ("MD5 digest:\r\n "+textchop(textupper(md5))+"\r\n\r\n")
endif
filedelete ftemp
textbox msg, 'Checksums'